/**
 * 
 */
package com.thor.palmmall.rest.common;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.UCN;
import com.thor.palmmall.rest.common.ADeviceRepairMaterial;
import com.thor.palmmall.spi.basic.SDeviceRepairMaterial;

/**
 * @author NuoSa
 *
 * @since 1.0
 */
public class ADeviceRepairMaterialConverter
    implements Converter<SDeviceRepairMaterial, ADeviceRepairMaterial> {

  public static ADeviceRepairMaterialConverter getInstance() {
    if (instance == null)
      instance = new ADeviceRepairMaterialConverter();
    return instance;
  }

  private static ADeviceRepairMaterialConverter instance;

  private ADeviceRepairMaterialConverter() {
  }

  @Override
  public ADeviceRepairMaterial convert(SDeviceRepairMaterial source) {
    if (source == null) {
      return null;
    }
    ADeviceRepairMaterial target = new ADeviceRepairMaterial();
    target.setMaterial(UCN.newInstance(source.getMaterial()));
    target.setWarehouse(UCN.newInstance(source.getWarehouse()));
    target.setTotal(ATotalConverter.getInstance().convert(source.getTotal()));
    return target;
  }

}
